Source for file tinyspell.php
Documentation is available at tinyspell.php
* $RCSfile: tinyspell.php,v $
* $Date: 2006/03/14 17:33:47 $
* @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.
// Ignore the Notice errors for now.
require_once("config.php");
if (!$spellCheckerConfig['enabled']) {
header('Content-type: text/xml; charset=utf-8');
echo
'<?xml version="1.0" encoding="utf-8" ?><res id="' .
$id .
'" error="true" msg="You must enable the spellchecker by modifying the config.php file." />';
$defaultLanguage =
$spellCheckerConfig['default.language'];
$defaultMode =
$spellCheckerConfig['default.mode'];
// Normaly not required to configure
$defaultSpelling =
$spellCheckerConfig['default.spelling'];
$defaultJargon =
$spellCheckerConfig['default.jargon'];
$defaultEncoding =
$spellCheckerConfig['default.encoding'];
$outputType =
"xml"; // Do not change
$lang =
sanitize($_REQUEST['lang'], "strict");
$mode =
sanitize($_REQUEST['mode'], "strict");
$spelling =
sanitize($_REQUEST['spelling'], "strict");
$jargon =
sanitize($_REQUEST['jargon'], "strict");
$encoding =
sanitize($_REQUEST['encoding'], "strict");
$sg =
sanitize($_REQUEST['sg'], "bool");
$lang =
$defaultLanguage;
$spelling =
$defaultSpelling;
$jargon =
$defaultJargon;
$encoding =
$defaultEncoding;
function sanitize($str, $type=
"strict") {
if ($str ==
"true" ||
$str ==
true)
$tinyspell =
new $spellCheckerConfig['class']($spellCheckerConfig, $lang, $mode, $spelling, $jargon, $encoding);
if (count($tinyspell->errorMsg) ==
0) {
// Space for non-exec version and \n for the exec version.
$words =
preg_split("/ |\n/", $check, -
1, PREG_SPLIT_NO_EMPTY);
$result =
$tinyspell->checkWords($words);
$result =
$tinyspell->getSuggestion($check);
// Just use this for now.
$tinyspell->errorMsg[] =
"No command.";
$outputType =
$outputType .
"error";
$outputType =
$outputType .
"error";
header('Content-type: text/xml; charset=utf-8');
$body =
'<?xml version="1.0" encoding="utf-8" ?>';
$body .=
'<res id="' .
$id .
'" cmd="'.
$cmd .
'" />';
$body .=
'<res id="' .
$id .
'" cmd="'.
$cmd .
'">'.
urlencode(implode(" ", $result)) .
'</res>';
header('Content-type: text/xml; charset=utf-8');
$body =
'<?xml version="1.0" encoding="utf-8" ?>';
$body .=
'<res id="' .
$id .
'" cmd="'.
$cmd .
'" error="true" msg="'.
implode(" ", $tinyspell->errorMsg) .
'" />';
Documentation generated on Mon, 05 May 2008 16:23:19 +0400 by phpDocumentor 1.4.0